﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Text.RegularExpressions;
using NHibernate.Criterion;


namespace LIB
{
    public class App_Constant
    {
        
        //Path
        public const string PATH_UP_IMAGE = "/userupload/images";
        public const string PATH_UP_IMAGES_NEWS = "/userupload/images/news";
        public const string PATH_UP_IMAGES_PRODUCT = "/userupload/images/product";
        public const string PATH_UP_IMAGES_HOME = "/userupload/images/home";
        public const string PATH_UP_IMAGES_MAP = "/userupload/images/map";
        public const string PATH_UP_IMAGES_SLIDE = "/userupload/images/slide";
        public const string PATH_UP_IMAGES_VEHICLE = "/userupload/images/vehicle";
        public const string PATH_UP_ADVENTISEMENT = "/userupload/adventure";
        public const string PATH_UP_CONTENT = "/userupload/images/content";
        public const string PATH_UP_USERAVATAR = "/userupload/images/user";
        
        public const string FUNNY = "babywash";
        public const string domain = "http://babywash.vn";

        public const int ROLE_ADMIN = 1;
        public const int ROLE_USER = 2;

        public const int STATUS_ONLY_YOU = 1;
        public const int STATUS_ONLY_FRIEND = 2;
        public const int STATUS_ALL = 3;

        public const int APPROVED = 1;
        public const int PENDING = 2;
        public const int DENY = 3;

        public const int OBJECT_ALBUM = 1;
        public const int OBJECT_VIDEO = 2;
        public const int OBJECT_NHATKY = 3;
        public const int OBJECT_QUICKCOM = 4;

        public static void EnsureDomain()
        {
            HttpContext context = HttpContext.Current;
            string rqdomain = (context.Request.UrlReferrer != null) ? context.Request.UrlReferrer.AbsoluteUri : "";
            string host = context.Request.Headers["Host"];
            if ((rqdomain.ToLower().IndexOf("babywash.vn") == -1 && host.ToLower().IndexOf("babywash.vn") == -1) || (rqdomain.ToLower().IndexOf("babyshower.vn") == -1 && host.ToLower().IndexOf("babyshower.vn") == -1))
            {
                throw new Exception("access is denied");
            }
            return;
        }

        public static ArrayList GetInternetLink(string Source)
        {
            ArrayList ResultList = new ArrayList();//|\w{1,}\.\w+(\.\w{2,3})*(/[^\s]+)?
            ArrayList res = new ArrayList();
            MatchCollection matchs = Regex.Matches(Source, @"http://\w{1,}\.\w+(\.\w{2,3})*(/[^\s]+)?|(www|www\d{1,})\.\w{1,}\.\w+(\.\w{2,3})*(/[^\s]+)?", RegexOptions.Multiline | RegexOptions.IgnoreCase);
            foreach (Match match in matchs)
            {
                ResultList.Add(match.ToString());
            }
            return ResultList;
        }

        public static IEnumerable<int> getGiaoCua2TapHop(int[] list1, int[] list2)
        {
            return list1.Intersect(list2);

        }
        public static IEnumerable<int> getHopCua2TapHop(int[] list1, int[] list2)
        {
            return list1.Union(list2);
        }
        public static IEnumerable<int> getHieuCua2TapHop(int[] list1, int[] list2)
        {
            return list1.Except(list2);
        }

        
   }  
    
}
